/*
 * Console.cs - Implementation of the
 *		"CSScript.Starter.Console" class.
 *
 * Copyright (C) 2008  Daniel Bedarf.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
using System;
using System.Collections.Generic;
using System.Text;

namespace CSScript.Starter
{
    class Console
    {
        static void Main(string[] args)
        {

            bool KeepFiles = false;
            foreach (string arg in args)
            {
                switch (arg)
                {
                    case "/keepfiles": KeepFiles = true; break;
                }
            }
            CSScript.BLogic.Runtime.Compiler comp = new CSScript.BLogic.Runtime.Compiler();
            if (comp.Compile(System.IO.File.ReadAllText(args[0]), KeepFiles))
            {
                List<string> rtargs = new List<string>(args);
                rtargs.RemoveAt(0);
                comp.Run(rtargs.ToArray());
            }
            else
            {
                System.Console.WriteLine(comp.Error.Message);
            }
        }
    }
}
